{extend name="public/base" /}
{block name="css"}
<style>
  #btn_zhuangtai input{
    width: 65px;text-align:center;border: 0px;background: #eee;padding: 5px;box-sizing: border-box;border-radius: 8px;
  }
</style>
{/block}
{block name="container"}
<body class="gray-bg">
  <div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
      <div class="col-sm-12">
        <div class="ibox float-e-margins">
          <div class="ibox-title">
            <h5>订单列表</h5>
            <div style="float: right;">
              <a  class="btn btn-w-m btn-info" href="{:url('index/order/create')}">录入订单</a>
            </div>
          </div>
          <div class="ibox-content">
            <div class="row">
                            <form action="" method="post">
                              <div class="col-sm-9 m-b-xs">
                               <div data-toggle="buttons" class="btn-group" id="btn_zhuangtai">

                                <button class="btn btn-sm btn-primary" style="border-top-right-radius:4px !important;border-bottom-right-radius:4px !important;" onclick="export_data()">导出全部数据</button>
                                &emsp;
                                <select name="chaxun" id="" class="btn btn-sm btn-primary" style="height: 30px;margin-left: 20px;box-sizing: border-box;border-radius: 4px;background-color: #6bba66;border-color: #6bba66;"  onchange="chakan(this.value)">
                                  <option value="all">全部订单</option>
                                  <option value="cai">待财审</option>
                                  <option value="confirm">待审核</option>
                                  <option value="ding">待定版</option>
                                  <option value="shang">待上传</option>
                                  <option value="xia">待下载</option>
                                  <option value="fa">待发货</option>
                                  <option value="yijing">已发货</option>
                                  <option value="bo">已驳回</option>
                                  <option value="zheng">正常订单</option>
                                  <option value="shou">售后订单</option>
                                  <option value="dai">代加工</option>
                                </select>
                               
                              </div>
                            </div> 
                          </form>
                          <form action="" method="post">
                            <div class="col-sm-3" style="float: right;">
                              <div class="input-group">
                                <input type="text" placeholder="请输入客户姓名" name="name" class="input-sm form-control"> <span class="input-group-btn">
                                  <button type="submit" class="btn btn-sm btn-primary"> 搜索</button> </span>
                                </div>
                              </div>
                            </form>

                          </div>
                          <div class="table-responsive">
                            <table class="table table-striped">
                              <thead>
                                <tr>
                                  <th></th>
                                  <th>序号</th>
                                  <th>客户姓名</th>
                                  <th>联系方式</th>
                                  <th>品类</th>
                                  <th>收货地址</th>
                                  <th>产品编号</th>
                                  <th>订单号
                                  </th>
                                  <th>录单时间</th>
                                  <th>订单状态</th>
                                  <th>操作</th>

                                </tr>
                              </thead>
                              <tbody>
                                <tr>
                                  {volist name="list" id="vo"}
                                  <td><input type="checkbox" class="i-checks"  name="input" value="{$vo.id}"> </td>
                                  <td>{$vo.id}</td>
                                  <td>{$vo.cust_name}</td>
                                  <td>{$vo.cust_phone}</td>
                                  <td>{$vo.pin}</td>
                                  <td>{$vo.dizhi}</td>
                                  <td>{$vo.pro_num}</td>
                                  <td>{$vo.order_num}</td>
                                  <td>{$vo['add_time']|date="Y-m-d H:i",###}</td>
                                  <td>
                                   {$vo.status}
                                 </td>
                                 <td>
                                  {$vo.cao ?? ''}
                                       
                                      </td>
                                    </tr>
                                    {/volist}
                                  </tbody>
                                </table>
                                <div style="float: right;">
                                 {$page}
                               </div>
                             </div>

                           </div>
                         </div>
                       </div>

                     </div>
                   </div>

                   <div id="modal-form" class="modal fade" aria-hidden="true">
                    <div class="modal-dialog">
                      <div class="modal-content">
                        <div class="modal-body">
                          <div class="row">
                            <div class="col-sm-12 b-r">
                              <h3 class="m-t-none m-b">上传文件</h3>
                              <form enctype="multipart/form-data" role="form" method="post" id="uploadForm" action="{:url('index/order/upload')}" >
                                <div class="form-group">
                                  <input type="hidden" name="order_id" id="order_id" value="">
                                  <input type="file" name="img" value=""> 
                                  <input type="submit" value="上传" style="margin-top:20px;" >
                                </div>
                              </form>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>

                  <div id="modal-form_yundan" class="modal fade" aria-hidden="true">
                    <div class="modal-dialog">
                      <div class="modal-content">
                        <div class="modal-body">
                          <div class="row">
                            <div class="col-sm-12 b-r">
                              <h3 class="m-t-none m-b">运单号：</h3>
                              <form role="form" action="{:url('index/order/yundan')}" method="post">
                                <div class="form-group">
                                  <input type="name" placeholder="请填入运单号" class="form-control" id="reaon" name="yundan_num">
                                  <input type="hidden" id="orderid_yun" name="orderid" value="">
                                </div>
                                <div>
                                  <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit"><strong>提交</strong>
                                  </button>
                                </div>
                              </form>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                  {/block}
                  {block name="js"}
                  <!-- Peity -->
                  <script src="__INDEX__/js/plugins/peity/jquery.peity.min.js"></script>
                  <!-- 自定义js -->
                  <script src="__INDEX__/js/content.js?v=1.0.0"></script>
                  <!-- iCheck -->
                  <script src="__INDEX__/js/plugins/iCheck/icheck.min.js"></script>
                  <script>
                    $(document).ready(function () {
                     // var status = {$Request.param.status};
                      $("[name='chaxun']").find("[value='{$Request.param.status ?? 'all'}']").attr("selected", true);
                      $('.i-checks').iCheck({
                        checkboxClass: 'icheckbox_square-green',
                        radioClass: 'iradio_square-green',
                      });
                    });
                  </script>
                  <script>
                    function chakan(obj)
                    {
                      window.location.href='/index/order/index/status/'+obj;
                    }
                    function getInfo(id)
                    {
                      $("#order_id").val(id);
                      $('#orderid_yun').val(id);
                    }

                    /*导出excel*/
                    function export_data()
                    {
                        window.location.href = '/index/order/excel';
       }
     </script>
     <script>
        // ajax的下载文件
        function xiazai(id)
        {
            //alert(id);
            $.post('{:url("index/order/ajaxDownload")}', {id: id}, function(data) {
             if(data.msg == -1){
              swal({
                title: "权限不足",
                text: "",
                type: "error"
              });
            }
            if(data.msg == 1){
             window.location.href= data.url;
               //window.location.reload();
             }
           });
          }
        </script>
        <script>
          function delorder(id)
          {
            swal({   
              title: "确定要删除数据?",   
              text: "确认将删除该条数据!",   
              type: "warning",   
              showCancelButton: true,    
              confirmButtonText: "确认", 
              cancelButtonText: '取消',
              closeOnConfirm: false
            }, function(){   
              $.post('{:url("index/order/delorder")}', {'id':id}, function(data) {
                if(data.sta == -1 ){
                  swal({
                    title: "权限不足",
                    text: "",
                    type: "error"
                  });
                }else if(data.sta == 1){
                 swal({
                  title: "删除成功",
                  text: "",
                  type: "success"
                });
                 window.location.reload();
               }else{
                swal({
                  title: "删除失败",
                  text: "",
                  type: "error"
                });                
              }
            });
            });
          }
        </script>
      </script>
      {/block}